package com.py.credit.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.entity.PublicDirectoryQuery;
import com.py.credit.service.PublicDirectoryQueryService;
import com.py.framework.core.common.Page;

@RestController
@RequestMapping("/publicDirectoryQueryController")
public class PublicDirectoryQueryController {

	@Autowired
	private PublicDirectoryQueryService publicDirectoryQueryService;

	@RequestMapping("/selectList.json")
	public RestServiceResult<Map<String, List<PublicDirectoryQuery>>> selectDeptList() {
		RestServiceResult<Map<String, List<PublicDirectoryQuery>>> result = new RestServiceResult<Map<String, List<PublicDirectoryQuery>>>();
		List<PublicDirectoryQuery> deptList = publicDirectoryQueryService.selectDeptList();
		List<PublicDirectoryQuery> dataBaseList = publicDirectoryQueryService.selectDataBaseList();
		Map<String, List<PublicDirectoryQuery>> mapResult = new HashMap<String, List<PublicDirectoryQuery>>();
		mapResult.put("deptList", deptList);
		mapResult.put("dataBaseList", dataBaseList);
		result.setData(mapResult);
		return result;
	}

	@RequestMapping("/selectWhereForPage.json")
	public RestServiceResult<List<PublicDirectoryQuery>> selectWhereForPage(String kId, String deptId,
			String sharingType, Page page, String title) {
		RestServiceResult<List<PublicDirectoryQuery>> result = new RestServiceResult<List<PublicDirectoryQuery>>();
		List<PublicDirectoryQuery> resultList = publicDirectoryQueryService.selectWhereForPage(kId, deptId, sharingType,
				page, title);
		result.setCount(page.getTotalCount());
		result.setData(resultList);
		return result;
	}

}
